package com.hyp.service.impl;

import com.hyp.mapper.AppointmentMapper;
import com.hyp.pojo.Appointment;
import com.hyp.pojo.AppointmentDTO;
import com.hyp.pojo.Product;
import com.hyp.service.AppointmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class AppointmentServicelmpl implements AppointmentService {
    @Autowired
    private AppointmentMapper appointmentMapper;

    @Override
    public void addAppoint(Appointment appointment) {
        appointment.setAppointmentStatus("已预约");
        appointment.setCreatedAt(LocalDateTime.now());
        appointment.setUpdatedAt(LocalDateTime.now());
        appointmentMapper.addAppoint(appointment);
    }

    @Override
    public List<Appointment> appointlist(Integer userId,String appointmentStatus) {
        return appointmentMapper.appointlist(userId,appointmentStatus);
    }

    @Override
    public Appointment appointlistById(Integer appointmentId) {
        return appointmentMapper.appointlistById(appointmentId);
    }

    @Override
    public void offappoint(Appointment appointment) {
        appointment.setAppointmentStatus("已取消");
        appointment.setUpdatedAt(LocalDateTime.now());
        appointmentMapper.offappoint(appointment);
    }

    @Override
    public List<Product> search(String description) {
        return appointmentMapper.search(description);
    }

    @Override
    public List<AppointmentDTO> allappointlist() {
        return appointmentMapper.allappointlist();
    }

    @Override
    public void finishappoint(Appointment appointment) {
        appointment.setAppointmentStatus("已完成");
        appointment.setUpdatedAt(LocalDateTime.now());
        appointmentMapper.finishappoint(appointment);
    }


}
